/** 
 *    
 *  Copyright (C) 2008 Marco Speranza <marco.speranza79@gmail.com>
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 */
package org.commons.database.jconnectionpool;

import java.io.PrintWriter;
import java.sql.SQLException;

import javax.sql.ConnectionPoolDataSource;
import javax.sql.PooledConnection;

public class ConnectionPoolDataSourceStub implements ConnectionPoolDataSource {

	private String url;
	private String user;
	private String password;
	
	
	
	public static int logialConnectionCount = 0;
	public static int phisicalConnectionCount = 0;
	
	public int throwsGetConnectionSqlException = 0;
	
	public PrintWriter getLogWriter() throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}

	public int getLoginTimeout() throws SQLException {
		// TODO Auto-generated method stub
		return 10;
	}

	public PooledConnection getPooledConnection() throws SQLException {
		// TODO Auto-generated method stub
		return this.getPooledConnection(null, null);
	}

	public PooledConnection getPooledConnection(String user, String password)
			throws SQLException {
		
		if (throwsGetConnectionSqlException == 3) throw new SQLException("FOR TEST ...");

		PooledConnectionStub res = new PooledConnectionStub(throwsGetConnectionSqlException);
		if ( throwsGetConnectionSqlException == 2 ) { 
			throwsGetConnectionSqlException = 0;
		}
		return  res;
	}

	public void setLogWriter(PrintWriter out) throws SQLException {
		// TODO Auto-generated method stub

	}

	public void setLoginTimeout(int seconds) throws SQLException {
		// TODO Auto-generated method stub

	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

}
